﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.Windows;
using System.Windows.Input;

using HA.Data;

using HA.ModFlow.Controls.Windows;

using HA.ModFlow.Controls.Windows.MapData;

using HA.ModFlow.Domain.DomainLayer;
using System.Windows.Controls;

namespace HA.ModFlow.Application
{
   public static class DataCommands
    {

       static DataCommands()
       {
           import = new RoutedCommand();

           importTxtCsv = new RoutedCommand();

           importBitmap = new RoutedCommand();

           importCAD = new RoutedCommand();

           importShape = new RoutedCommand();

           importDem = new RoutedCommand();

           exportBitmap = new RoutedCommand();


          
           addGrid2D = new RoutedCommand();
           removeGrid2D = new RoutedCommand();
           addGrid3D = new RoutedCommand();
           removeGrid3D = new RoutedCommand();
           addBorehole = new RoutedCommand();
           removeBorehole = new RoutedCommand();
           addTin = new RoutedCommand();
           removeTin = new RoutedCommand();



           //关于mapdata的专题

           addCoverage = new RoutedCommand();
           removeCoverage = new RoutedCommand();
           addConceptualModel = new RoutedCommand();
           removeConceptualModel = new RoutedCommand();


           addCMCoverage = new RoutedCommand();
           removeCMCoverage = new RoutedCommand();
           duplicateCMCoverage = new RoutedCommand();



           addGridFrame = new RoutedCommand();
           removeGridFrame = new RoutedCommand();





           coverageSetup = new RoutedCommand();
           conceptualModelProperty = new RoutedCommand();

           //gridframeProperty = new RoutedCommand();


           coverageAttributeTable = new RoutedCommand();



           //mapto about

           cmMapToModFlow = new RoutedCommand();
           coverageMapToModFlow = new RoutedCommand();


           cmMapToMT3D = new RoutedCommand();

           coverageMapToMT3D = new RoutedCommand();



           gridFrameMapToGrid3d = new RoutedCommand();


           gridFrameFitToCoverage = new RoutedCommand();

           gridFrameProp = new RoutedCommand();



           activeCellsInCoverage = new RoutedCommand();

           coverageMap3DGrid = new RoutedCommand();


           buildPolygon = new RoutedCommand();




           ///模型相关



           addModflow = new RoutedCommand();

           removeModflow = new RoutedCommand();


           addMT3DMS = new RoutedCommand();

           removeMT3DMS = new RoutedCommand();


          
       }


       #region 模型命令

       static RoutedCommand addModflow;

       public static RoutedCommand AddModflow
       {
           get { return DataCommands.addModflow; }
          
       }
       static RoutedCommand removeModflow;

       public static RoutedCommand RemoveModflow
       {
           get { return DataCommands.removeModflow; }
         
       }

       static RoutedCommand addMT3DMS;

       public static RoutedCommand AddMT3DMS
       {
           get { return DataCommands.addMT3DMS; }
          
       }
       static RoutedCommand removeMT3DMS;

       public static RoutedCommand RemoveMT3DMS
       {
           get { return DataCommands.removeMT3DMS; }
          
       }


       #endregion


       #region 其他

    
       static RoutedCommand addGrid2D;

       public static RoutedCommand AddGrid2D
       {
           get { return DataCommands.addGrid2D; }          
       }
       static RoutedCommand removeGrid2D;

       public static RoutedCommand RemoveGrid2D
       {
           get { return DataCommands.removeGrid2D; }          
       }

       static RoutedCommand addGrid3D;

       public static RoutedCommand AddGrid3D
       {
           get { return DataCommands.addGrid3D; }         
       }

       static RoutedCommand removeGrid3D;

       public static RoutedCommand RemoveGrid3D
       {
           get { return DataCommands.removeGrid3D; }         
       }

       static RoutedCommand addBorehole;

       public static RoutedCommand AddBorehole
       {
           get { return DataCommands.addBorehole; }       
       }
       static RoutedCommand removeBorehole;

       public static RoutedCommand RemoveBorehole
       {
           get { return DataCommands.removeBorehole; }     
       }

       static RoutedCommand addTin;

       public static RoutedCommand AddTin
       {
           get { return DataCommands.addTin; }          
       }
       static RoutedCommand removeTin;

       public static RoutedCommand RemoveTin
       {
           get { return DataCommands.removeTin; }       
       }


#endregion


       #region mapdata相关

       static RoutedCommand addCoverage;

       public static RoutedCommand AddCoverage
       {
           get { return DataCommands.addCoverage; }          
       }
       static RoutedCommand removeCoverage;

       public static RoutedCommand RemoveCoverage
       {
           get { return DataCommands.removeCoverage; }         
       }

       static RoutedCommand addConceptualModel;

       public static RoutedCommand AddConceptualModel
       {
           get { return DataCommands.addConceptualModel; }          
       }
       static RoutedCommand removeConceptualModel;

       public static RoutedCommand RemoveConceptualModel
       {
           get { return DataCommands.removeConceptualModel; }         
       }


       static RoutedCommand addCMCoverage;

       public static RoutedCommand AddCMCoverage
       {
           get { return DataCommands.addCMCoverage; }
          
       }

       static RoutedCommand removeCMCoverage;

       public static RoutedCommand RemoveCMCoverage
       {
           get { return DataCommands.removeCMCoverage; }
          
       }

       static RoutedCommand duplicateCMCoverage;

       public static RoutedCommand DuplicateCMCoverage
       {
           get { return DataCommands.duplicateCMCoverage; }
          
       }



       static RoutedCommand coverageSetup;

       public static RoutedCommand CoverageSetup
       {
           get { return DataCommands.coverageSetup; }
          
       }

       static RoutedCommand conceptualModelProperty;

       public static RoutedCommand ConceptualModelProperty
       {
           get { return DataCommands.conceptualModelProperty; }
          
       }


       static RoutedCommand addGridFrame;

       public static RoutedCommand AddGridFrame
       {
           get { return DataCommands.addGridFrame; }
           
       }

       static RoutedCommand removeGridFrame;

       public static RoutedCommand RemoveGridFrame
       {
           get { return DataCommands.removeGridFrame; }
          
       }

       //static RoutedCommand gridframeProperty;

       //public static RoutedCommand GridframeProperty
       //{
       //    get { return DataCommands.gridframeProperty; }
          
       //}


       static RoutedCommand coverageAttributeTable;

       public static RoutedCommand CoverageAttributeTable
       {
           get { return DataCommands.coverageAttributeTable; }
         
       }


       //mapto相关


       static RoutedCommand cmMapToModFlow;

       public static RoutedCommand CmMapToModFlow
       {
           get { return DataCommands.cmMapToModFlow; }
           
       }


       static RoutedCommand coverageMapToModFlow;

       public static RoutedCommand CoverageMapToModFlow
       {
           get { return DataCommands.coverageMapToModFlow; }
          
       }


       static RoutedCommand cmMapToMT3D;

       public static RoutedCommand CmMapToMT3D
       {
           get { return DataCommands.cmMapToMT3D; }
         
       }

       static RoutedCommand coverageMapToMT3D;

       public static RoutedCommand CoverageMapToMT3D
       {
           get { return DataCommands.coverageMapToMT3D; }
          
       }






       static RoutedCommand gridFrameMapToGrid3d;

       public static RoutedCommand GridFrameMapToGrid3d
       {
           get { return DataCommands.gridFrameMapToGrid3d; }
          
       }


       static RoutedCommand gridFrameFitToCoverage;

       public static RoutedCommand GridFrameFitToCoverage
       {
           get { return DataCommands.gridFrameFitToCoverage; }
          
       }


       static RoutedCommand gridFrameProp;

       public static RoutedCommand GridFrameProp
       {
           get { return DataCommands.gridFrameProp; }
          
       }



       static RoutedCommand activeCellsInCoverage;

       public static RoutedCommand ActiveCellsInCoverage
       {
           get { return DataCommands.activeCellsInCoverage; }
        
       }

       static RoutedCommand coverageMap3DGrid;

       public static RoutedCommand CoverageMap3DGrid
       {
           get { return DataCommands.coverageMap3DGrid; }
          

       }


       static RoutedCommand buildPolygon;

       public static RoutedCommand BuildPolygon
       {
           get { return DataCommands.buildPolygon; }
           
       }


       #endregion



       public static Window mainWindow;

       static RoutedCommand importTxtCsv;

       public static RoutedCommand ImportTxtCsv
       {
           get { return DataCommands.importTxtCsv; }          
       }

       static RoutedCommand _InterpolationOption = new RoutedCommand();
       /// <summary>
       /// 差值选项
       /// </summary>
       public static RoutedCommand InterpolationOption
       {
           get { return DataCommands._InterpolationOption; }
          
       }
    
    

       static RoutedCommand importBitmap;

       public static RoutedCommand ImportBitmap
       {
           get { return DataCommands.importBitmap; }
         
       }

       static RoutedCommand importCAD;

       public static RoutedCommand ImportCAD
       {
           get { return DataCommands.importCAD; }
          
       }

       static RoutedCommand importShape;

       public static RoutedCommand ImportShape
       {
           get { return DataCommands.importShape; }
          
       }

       static RoutedCommand importDem;

       public static RoutedCommand ImportDem
       {
           get { return DataCommands.importDem; }
           set { DataCommands.importDem = value; }
       }


       static RoutedCommand import;

       public static RoutedCommand Import
       {
           get { return DataCommands.import; }
           
       }

       static RoutedCommand exportBitmap;

       public static RoutedCommand ExportBitmap
       {
           get { return DataCommands.exportBitmap; }
       }



       public static void BindCommandsToWindow(Window window)
       {
           CommandBinding cbImport = new CommandBinding();
           cbImport.Command = import;
           cbImport.CanExecute += new CanExecuteRoutedEventHandler(cbImport_CanExecute);
           cbImport.Executed += new ExecutedRoutedEventHandler(cbImport_Executed);
           window.CommandBindings.Add(cbImport);



           CommandBinding cbImportTxt = new CommandBinding();
           cbImportTxt.Command = importTxtCsv;
           cbImportTxt.CanExecute += new CanExecuteRoutedEventHandler(cbImportTxt_CanExecute);
           cbImportTxt.Executed += new ExecutedRoutedEventHandler(cbImportTxt_Executed);
           window.CommandBindings.Add(cbImportTxt);



           CommandBinding cbImportBitmap = new CommandBinding();
           cbImportBitmap.Command = importBitmap;
           cbImportBitmap.CanExecute += new CanExecuteRoutedEventHandler(cbImportBitmap_CanExecute);
           cbImportBitmap.Executed += new ExecutedRoutedEventHandler(cbImportBitmap_Executed);
           window.CommandBindings.Add(cbImportBitmap);



           CommandBinding cbImportCAD = new CommandBinding();
           cbImportCAD.Command = importCAD;
           cbImportCAD.CanExecute += new CanExecuteRoutedEventHandler(cbImportCAD_CanExecute);
           cbImportCAD.Executed += new ExecutedRoutedEventHandler(cbImportCAD_Executed);
           window.CommandBindings.Add(cbImportCAD);


           CommandBinding cbImportShape = new CommandBinding();
           cbImportShape.Command = importShape;
           cbImportShape.CanExecute += new CanExecuteRoutedEventHandler(cbImportShape_CanExecute);
           cbImportShape.Executed += new ExecutedRoutedEventHandler(cbImportShape_Executed);
           window.CommandBindings.Add(cbImportShape);

           CommandBinding cbImportDem = new CommandBinding();
           cbImportDem.Command = importDem;
           cbImportDem.Executed += new ExecutedRoutedEventHandler(cbImportDem_Executed);
           cbImportDem.CanExecute += new CanExecuteRoutedEventHandler(cbImportDem_CanExecute);
           window.CommandBindings.Add(cbImportDem);

           CommandBinding cbExportBitmap = new CommandBinding();
           cbExportBitmap.Command = exportBitmap;
           cbExportBitmap.CanExecute+=new CanExecuteRoutedEventHandler(cbExportBitmap_CanExecute);
           cbExportBitmap.Executed+=new ExecutedRoutedEventHandler(cbExportBitmap_Executed);
           window.CommandBindings.Add(cbExportBitmap);
   

           CommandBinding cbAddGrid2D = new CommandBinding();
           cbAddGrid2D.Command = addGrid2D;
           cbAddGrid2D.CanExecute += new CanExecuteRoutedEventHandler(cbAddGrid2D_CanExecute);
           cbAddGrid2D.Executed += new ExecutedRoutedEventHandler(cbAddGrid2D_Executed);
           window.CommandBindings.Add(cbAddGrid2D);

           CommandBinding cbRemoveGrid2D = new CommandBinding();
           cbRemoveGrid2D.Command = removeGrid2D;
           cbRemoveGrid2D.CanExecute += new CanExecuteRoutedEventHandler(cbRemoveGrid2D_CanExecute);
           cbRemoveGrid2D.Executed += new ExecutedRoutedEventHandler(cbRemoveGrid2D_Executed);
           window.CommandBindings.Add(cbRemoveGrid2D);

           CommandBinding cbAddGrid3D = new CommandBinding();
           cbAddGrid3D.Command = addGrid3D;
           cbAddGrid3D.CanExecute += new CanExecuteRoutedEventHandler(cbAddGrid3D_CanExecute);
           cbAddGrid3D.Executed += new ExecutedRoutedEventHandler(cbAddGrid3D_Executed);
           window.CommandBindings.Add(cbAddGrid3D);

           CommandBinding cbRemoveGrid3D = new CommandBinding();
           cbRemoveGrid3D.Command = removeGrid3D;
           cbRemoveGrid3D.CanExecute += new CanExecuteRoutedEventHandler(cbRemoveGrid3D_CanExecute);
           cbRemoveGrid3D.Executed += new ExecutedRoutedEventHandler(cbRemoveGrid3D_Executed);
           window.CommandBindings.Add(cbRemoveGrid3D);

           CommandBinding cbAddBorehole = new CommandBinding();
           cbAddBorehole.Command = addBorehole;
           cbAddBorehole.CanExecute += new CanExecuteRoutedEventHandler(cbAddBorehole_CanExecute);
           cbAddBorehole.Executed += new ExecutedRoutedEventHandler(cbAddBorehole_Executed);
           window.CommandBindings.Add(cbAddBorehole);

           CommandBinding cbRemoveBorehole = new CommandBinding();
           cbRemoveBorehole.Command = removeBorehole;
           cbRemoveBorehole.CanExecute += new CanExecuteRoutedEventHandler(cbRemoveBorehole_CanExecute);
           cbRemoveBorehole.Executed += new ExecutedRoutedEventHandler(cbRemoveBorehole_Executed);
           window.CommandBindings.Add(cbRemoveBorehole);

           CommandBinding cbAddTin = new CommandBinding();
           cbAddTin.Command = addTin;
           cbAddTin.CanExecute += new CanExecuteRoutedEventHandler(cbAddTin_CanExecute);
           cbAddTin.Executed += new ExecutedRoutedEventHandler(cbAddTin_Executed);
           window.CommandBindings.Add(cbAddTin);

           CommandBinding cbRemoveTin = new CommandBinding();
           cbRemoveTin.Command = removeTin;
           cbRemoveTin.CanExecute += new CanExecuteRoutedEventHandler(cbRemoveTin_CanExecute);
           cbRemoveTin.Executed += new ExecutedRoutedEventHandler(cbRemoveTin_Executed);
           window.CommandBindings.Add(cbRemoveTin);





           //mapdata 图层相关的命令


           CommandBinding cbAddCoverage = new CommandBinding();
           cbAddCoverage.Command = addCoverage;
           cbAddCoverage.CanExecute += new CanExecuteRoutedEventHandler(cbAddCoverage_CanExecute);
           cbAddCoverage.Executed += new ExecutedRoutedEventHandler(cbAddCoverage_Executed);
           window.CommandBindings.Add(cbAddCoverage);

           CommandBinding cbRemoveCoverage = new CommandBinding();
           cbRemoveCoverage.Command = removeCoverage;
           cbRemoveCoverage.CanExecute += new CanExecuteRoutedEventHandler(cbRemoveCoverage_CanExecute);
           cbRemoveCoverage.Executed += new ExecutedRoutedEventHandler(cbRemoveCoverage_Executed);
           window.CommandBindings.Add(cbRemoveCoverage);

           CommandBinding cbAddConceptualModel = new CommandBinding();
           cbAddConceptualModel.Command = addConceptualModel;
           cbAddConceptualModel.CanExecute += new CanExecuteRoutedEventHandler(cbAddConceptualModel_CanExecute);
           cbAddConceptualModel.Executed += new ExecutedRoutedEventHandler(cbAddConceptualModel_Executed);
           window.CommandBindings.Add(cbAddConceptualModel);

           CommandBinding cbRemoveConceptualModel = new CommandBinding();
           cbRemoveConceptualModel.Command = removeConceptualModel;
           cbRemoveConceptualModel.CanExecute += new CanExecuteRoutedEventHandler(cbRemoveConceptualModel_CanExecute);
           cbRemoveConceptualModel.Executed += new ExecutedRoutedEventHandler(cbRemoveConceptualModel_Executed);
           window.CommandBindings.Add(cbRemoveConceptualModel);



           CommandBinding cbAddCmCoverage = new CommandBinding();
           cbAddCmCoverage.Command = addCMCoverage;
           cbAddCmCoverage.CanExecute += new CanExecuteRoutedEventHandler(cbAddCmCoverage_CanExecute);
           cbAddCmCoverage.Executed += new ExecutedRoutedEventHandler(cbAddCmCoverage_Executed);
           window.CommandBindings.Add(cbAddCmCoverage);


           CommandBinding cbRemoveCmCoverage = new CommandBinding();
           cbRemoveCmCoverage.Command = removeCMCoverage;
           cbRemoveCmCoverage.CanExecute += new CanExecuteRoutedEventHandler(cbRemoveCmCoverage_CanExecute);
           cbRemoveCmCoverage.Executed += new ExecutedRoutedEventHandler(cbRemoveCmCoverage_Executed);
           window.CommandBindings.Add(cbRemoveCmCoverage);


           CommandBinding cbDuplicateCmCoverage = new CommandBinding();
           cbDuplicateCmCoverage.Command = duplicateCMCoverage;
           cbDuplicateCmCoverage.CanExecute += new CanExecuteRoutedEventHandler(cbDuplicateCmCoverage_CanExecute);
           cbDuplicateCmCoverage.Executed += new ExecutedRoutedEventHandler(cbDuplicateCmCoverage_Executed);
           window.CommandBindings.Add(cbDuplicateCmCoverage);



           //

           CommandBinding cbCoverageSetup = new CommandBinding();
           cbCoverageSetup.Command = coverageSetup;
           cbCoverageSetup.CanExecute += new CanExecuteRoutedEventHandler(cbCoverageSetup_CanExecute);
           cbCoverageSetup.Executed += new ExecutedRoutedEventHandler(cbCoverageSetup_Executed);
           window.CommandBindings.Add(cbCoverageSetup);


           CommandBinding cbConceptualModelProperty = new CommandBinding();
           cbConceptualModelProperty.Command = conceptualModelProperty;
           cbConceptualModelProperty.CanExecute += new CanExecuteRoutedEventHandler(cbConceptualModelProperty_CanExecute);
           cbConceptualModelProperty.Executed += new ExecutedRoutedEventHandler(cbConceptualModelProperty_Executed);
           window.CommandBindings.Add(cbConceptualModelProperty);


           //CommandBinding cbGridFrameProperty = new CommandBinding();
           //cbGridFrameProperty.Command = gridFrameProp;
           //cbGridFrameProperty.CanExecute += new CanExecuteRoutedEventHandler(cbGridFrameProperty_CanExecute);
           //cbGridFrameProperty.Executed += new ExecutedRoutedEventHandler(cbGridFrameProperty_Executed);
           //window.CommandBindings.Add(cbGridFrameProperty);




           CommandBinding cbCoverageAttTable = new CommandBinding();
           cbCoverageAttTable.Command = coverageAttributeTable;
           cbCoverageAttTable.CanExecute += new CanExecuteRoutedEventHandler(cbCoverageAttTable_CanExecute);
           cbCoverageAttTable.Executed += new ExecutedRoutedEventHandler(cbCoverageAttTable_Executed);
           window.CommandBindings.Add(cbCoverageAttTable);







           //mapto 相关

           CommandBinding cbCMMaptoModFlow = new CommandBinding();
           cbCMMaptoModFlow.Command = cmMapToModFlow;
           cbCMMaptoModFlow.CanExecute += new CanExecuteRoutedEventHandler(cbCMMaptoModFlow_CanExecute);
           cbCMMaptoModFlow.Executed += new ExecutedRoutedEventHandler(cbCMMaptoModFlow_Executed);
           window.CommandBindings.Add(cbCMMaptoModFlow);


           CommandBinding cbCoverageMapToModFlow = new CommandBinding();
           cbCoverageMapToModFlow.Command = coverageMapToModFlow;
           cbCoverageMapToModFlow.CanExecute += new CanExecuteRoutedEventHandler(cbCoverageMapToModFlow_CanExecute);
           cbCoverageMapToModFlow.Executed += new ExecutedRoutedEventHandler(cbCoverageMapToModFlow_Executed);
           window.CommandBindings.Add(cbCoverageMapToModFlow);




           CommandBinding cbGridFrameFitToCoverage = new CommandBinding();
           cbGridFrameFitToCoverage.Command = gridFrameFitToCoverage;
           cbGridFrameFitToCoverage.CanExecute += new CanExecuteRoutedEventHandler(cbGridFrameFitToCoverage_CanExecute);
           cbGridFrameFitToCoverage.Executed += new ExecutedRoutedEventHandler(cbGridFrameFitToCoverage_Executed);
           window.CommandBindings.Add(cbGridFrameFitToCoverage);




           CommandBinding cbGridFrameMapToGrid3D = new CommandBinding();
           cbGridFrameMapToGrid3D.Command = gridFrameMapToGrid3d;
           cbGridFrameMapToGrid3D.CanExecute += new CanExecuteRoutedEventHandler(cbGridFrameMapToGrid3D_CanExecute);
           cbGridFrameMapToGrid3D.Executed += new ExecutedRoutedEventHandler(cbGridFrameMapToGrid3D_Executed);
           window.CommandBindings.Add(cbGridFrameMapToGrid3D);



           CommandBinding cbGridFrameProp = new CommandBinding();
           cbGridFrameProp.Command = gridFrameProp;
           cbGridFrameProp.CanExecute += new CanExecuteRoutedEventHandler(cbGridFrameProp_CanExecute);
           cbGridFrameProp.Executed += new ExecutedRoutedEventHandler(cbGridFrameProp_Executed);
           window.CommandBindings.Add(cbGridFrameProp);





           CommandBinding cbCoverageMap3DGrid = new CommandBinding();
           cbCoverageMap3DGrid.Command = coverageMap3DGrid;
           cbCoverageMap3DGrid.CanExecute += new CanExecuteRoutedEventHandler(cbCoverageMap3DGrid_CanExecute);
           cbCoverageMap3DGrid.Executed += new ExecutedRoutedEventHandler(cbCoverageMap3DGrid_Executed);
           window.CommandBindings.Add(cbCoverageMap3DGrid);



           CommandBinding cbActiveCellsInCoverage = new CommandBinding();
           cbActiveCellsInCoverage.Command = activeCellsInCoverage;
           cbActiveCellsInCoverage.CanExecute += new CanExecuteRoutedEventHandler(cbActiveCellsInCoverage_CanExecute);
           cbActiveCellsInCoverage.Executed += new ExecutedRoutedEventHandler(cbActiveCellsInCoverage_Executed);
           window.CommandBindings.Add(cbActiveCellsInCoverage);





           CommandBinding cbBuildPolygon = new CommandBinding();
           cbBuildPolygon.Command = buildPolygon;
           cbBuildPolygon.CanExecute += new CanExecuteRoutedEventHandler(cbBuildPolygon_CanExecute);
           cbBuildPolygon.Executed += new ExecutedRoutedEventHandler(cbBuildPolygon_Executed);

           window.CommandBindings.Add(cbBuildPolygon);





           //模型命令

           CommandBinding cbAddModflow = new CommandBinding();
           cbAddModflow.Command = addModflow;
           cbAddModflow.CanExecute += new CanExecuteRoutedEventHandler(cbAddModflow_CanExecute);
           cbAddModflow.Executed += new ExecutedRoutedEventHandler(cbAddModflow_Executed);

           window.CommandBindings.Add(cbAddModflow);

           CommandBinding cbRemoveModflow = new CommandBinding();
           cbRemoveModflow.Command = RemoveModflow;
           cbRemoveModflow.CanExecute += new CanExecuteRoutedEventHandler(cbRemoveModflow_CanExecute);
           cbRemoveModflow.Executed += new ExecutedRoutedEventHandler(cbRemoveModflow_Executed);

           window.CommandBindings.Add(cbRemoveModflow);



           CommandBinding cbAddMT3d = new CommandBinding();
           cbAddMT3d.Command = addMT3DMS;
           cbAddMT3d.CanExecute += new CanExecuteRoutedEventHandler(cbAddMT3d_CanExecute);
           cbAddMT3d.Executed += new ExecutedRoutedEventHandler(cbAddMT3d_Executed);

           window.CommandBindings.Add(cbAddMT3d);



           CommandBinding cbRemoveMT3d = new CommandBinding();
           cbRemoveMT3d.Command = removeMT3DMS;
           cbRemoveMT3d.CanExecute += new CanExecuteRoutedEventHandler(cbRemoveMT3d_CanExecute);
           cbRemoveMT3d.Executed += new ExecutedRoutedEventHandler(cbRemoveMT3d_Executed);

           window.CommandBindings.Add(cbRemoveMT3d);





           //gridframe的添加与删除


           CommandBinding cbAddGridFrame = new CommandBinding();
           cbAddGridFrame.Command = addGridFrame;
           cbAddGridFrame.CanExecute += new CanExecuteRoutedEventHandler(cbAddGridFrame_CanExecute);
           cbAddGridFrame.Executed += new ExecutedRoutedEventHandler(cbAddGridFrame_Executed);

           window.CommandBindings.Add(cbAddGridFrame);


           CommandBinding cbRemoveGridFrame = new CommandBinding();
           cbRemoveGridFrame.Command = removeGridFrame;
           cbRemoveGridFrame.CanExecute += new CanExecuteRoutedEventHandler(cbRemoveGridFrame_CanExecute);
           cbRemoveGridFrame.Executed += new ExecutedRoutedEventHandler(cbRemoveGridFrame_Executed);

           window.CommandBindings.Add(cbRemoveGridFrame);





           ///mapto mt3dms

           CommandBinding cbCMMaptoMT3DMS= new CommandBinding();
           cbCMMaptoMT3DMS.Command = cmMapToMT3D;
           cbCMMaptoMT3DMS.CanExecute += new CanExecuteRoutedEventHandler(cbCMMaptoMT3DMS_CanExecute);
           cbCMMaptoMT3DMS.Executed += new ExecutedRoutedEventHandler(cbCMMaptoMT3DMS_Executed);
           window.CommandBindings.Add(cbCMMaptoMT3DMS);


           CommandBinding cbCoverageMapToMT3D = new CommandBinding();
           cbCoverageMapToMT3D.Command = coverageMapToMT3D;
           cbCoverageMapToMT3D.CanExecute += new CanExecuteRoutedEventHandler(cbCoverageMapToMT3D_CanExecute);
           cbCoverageMapToMT3D.Executed += new ExecutedRoutedEventHandler(cbCoverageMapToMT3D_Executed);
           window.CommandBindings.Add(cbCoverageMapToMT3D);


           CommandBinding cbInterpolation = new CommandBinding();
           cbInterpolation.Command = _InterpolationOption;
           cbInterpolation.Executed += new ExecutedRoutedEventHandler(cbInterpolation_Executed);
           cbInterpolation.CanExecute += new CanExecuteRoutedEventHandler(cbInterpolation_CanExecute);
           window.CommandBindings.Add(cbInterpolation);
       }

       static void cbInterpolation_CanExecute(object sender, CanExecuteRoutedEventArgs e)
       {
           if (!ProjectService.DefaultService.BNullProj)
           {
               e.CanExecute = true;
           }
       }

       static void cbInterpolation_Executed(object sender, ExecutedRoutedEventArgs e)
       {
           HA.ModFlow.Controls.Windows.InterOptionTemporary.winTempInter win = new Controls.Windows.InterOptionTemporary.winTempInter(ProjectService.DefaultService.Project.InterpolationOption2D);
           //HA.ModFlow.Controls.Windows.DataOperation.win2DInterOptions win = new Controls.Windows.DataOperation.win2DInterOptions(ProjectSerivce.DefaultService.Project);
        
           win.Owner = mainWindow;
           if (win.ShowDialog().Value)
           {
               ProjectService.DefaultService.Project.InterpolationOption2D.ResetConfrm(win.InterOption);
           }
       }

       static void cbImport_Executed(object sender, ExecutedRoutedEventArgs e)
       {
          
       }

       static void cbImport_CanExecute(object sender, CanExecuteRoutedEventArgs e)
       {
           e.CanExecute = !ProjectService.DefaultService.BNullProj;
       }

       static void cbCoverageMapToMT3D_Executed(object sender, ExecutedRoutedEventArgs e)
       {
           //throw new NotImplementedException();
           Coverage c = e.Parameter as Coverage;

           List<Coverage> lst = new List<Coverage>();
           lst.Add(c);

           c.ParentCM.MapToMT3DMS(ProjectService.DefaultService.Project.Mt3dmsData,lst,false,true);


       }

       static void cbCoverageMapToMT3D_CanExecute(object sender, CanExecuteRoutedEventArgs e)
       {
           if (!ProjectService.DefaultService.BNullProj)
           {
               if (ProjectService.DefaultService.Project.Mt3dmsData != null)
               {
                   e.CanExecute = true;
 
               }
               
           }
       }

       static void cbCMMaptoMT3DMS_Executed(object sender, ExecutedRoutedEventArgs e)
       {
           //bool isMapVisibleOnly = true;
           //switch (System.Windows.MessageBox.Show("是否只映射可见图层？如只映射可见图层点是！全部映射点否！", "提示", MessageBoxButton.YesNoCancel, MessageBoxImage.Information))
           //{
           //    case MessageBoxResult.Cancel:
           //        return;
           //    case MessageBoxResult.No:
           //        isMapVisibleOnly = false;
           //        break;
           //    case MessageBoxResult.None:
           //        return;
           //    case MessageBoxResult.OK:
           //        isMapVisibleOnly = true;
           //        break;
           //    case MessageBoxResult.Yes:
           //        isMapVisibleOnly = true;
           //        break;
           //    default:
           //        break;
           //}
           bool isNewMT3D = false;

           ConceptualModel cm = e.Parameter as ConceptualModel;

           //判断Modflow是否已建立
           if (ProjectService.DefaultService.Project.MfData == null)
           {
               ProjectService.DefaultService.Project.NewModflow();
               ProjectService.DefaultService.Project.MfData.StressPeriods.InnerList.Clear();
               for (int i = 0; i < cm.Model.NPeriods; i++)
               {
                   ProjectService.DefaultService.Project.MfData.StressPeriods.InnerList.Add(new StressPeriod());
               }

               ProjectService.DefaultService.Project.MfData.ModelOption.InnerPack = cm.Model.InnerPack;
           }
           //判断MT3DMS是否已建立
           if (ProjectService.DefaultService.Project.Mt3dmsData == null)
           {
               isNewMT3D = true;
               ProjectService.DefaultService.Project.NewMt3dms();


               ProjectService.DefaultService.Project.Mt3dmsData.BasicTransport.StressPeriod.Periods.Clear();
               for (int i = 0; i < cm.Model.NPeriods; i++)
               {
                   ProjectService.DefaultService.Project.Mt3dmsData.BasicTransport.StressPeriod.Periods.Add(new MT3DMS.DomainLayer.MTStressPeriod());
               }



               //首先进行污染物的对比,这边类型没有必要做成mtspecies,直接做string 就可以了


               //首先判断数量，然后判断内容

               ProjectService.DefaultService.Project.Mt3dmsData.BasicTransport.SpeciesCollecion.Species.Clear();

               List<MT3DMS.DomainLayer.MTSpecies> lst = new List<MT3DMS.DomainLayer.MTSpecies>();
               for (int i = 0; i < cm.Model.SpeList.Count; i++)
               {
                   lst.Add(
                       new MT3DMS.DomainLayer.MTSpecies("物种_" + (i+1), true, 
                       ProjectService.DefaultService.Project.Mt3dmsData.BasicTransport.Grid.Nrows, 
                       ProjectService.DefaultService.Project.Mt3dmsData.BasicTransport.Grid.Ncols, 
                       ProjectService.DefaultService.Project.Mt3dmsData.BasicTransport.Grid.Nlayers)
                       );
               }
               
               ProjectService.DefaultService.Project.Mt3dmsData.BasicTransport.SpeciesCollecion.ResetSpecies(lst);
           }


           cm.MapToMT3DMS(ProjectService.DefaultService.Project.Mt3dmsData,isNewMT3D);
           
       }

       static void cbCMMaptoMT3DMS_CanExecute(object sender, CanExecuteRoutedEventArgs e)
       {
           if (!ProjectService.DefaultService.BNullProj && ProjectService.DefaultService.Project.Grid3dData.Grids.Count >0)
           {
               e.CanExecute = true;
           }
       }

       static void cbRemoveGridFrame_Executed(object sender, ExecutedRoutedEventArgs e)
       {
           ProjectService.DefaultService.Project.MapData.RemoveGridFrame();
           
       }

       static void cbRemoveGridFrame_CanExecute(object sender, CanExecuteRoutedEventArgs e)
       {
           e.CanExecute = !ProjectService.DefaultService.BNullProj;
       }

       static void cbAddGridFrame_Executed(object sender, ExecutedRoutedEventArgs e)
       {
          DotSpatial.Data.Extent ext=  GisModule.DefaultModule.DefaultMap.ViewExtents;

          double x = ext.MinX;
          double y = ext.MinY;

          double xleng = ext.Width;

          double yleng = ext.Height;


         

           GridFrame gf = new GridFrame();

           gf.XOrg = x + xleng * (1 - 0.6) * 0.5;
           gf.YOrg = y + yleng * (1 - 0.6) * 0.5;

           gf.XLength = xleng * 0.6;
           gf.YLength = yleng*0.6;



           ProjectService.DefaultService.Project.MapData.AddGridFrame(gf);
          
       }

       static void cbAddGridFrame_CanExecute(object sender, CanExecuteRoutedEventArgs e)
       {
           e.CanExecute = !ProjectService.DefaultService.BNullProj;
       }

       static void cbRemoveMT3d_Executed(object sender, ExecutedRoutedEventArgs e)
       {

           ProjectService.DefaultService.Project.DeleteMT3dMs();
       }

       static void cbRemoveMT3d_CanExecute(object sender, CanExecuteRoutedEventArgs e)
       {
           e.CanExecute = !ProjectService.DefaultService.BNullProj;
       }

       static void cbAddMT3d_Executed(object sender, ExecutedRoutedEventArgs e)
       {

           if (ProjectService.DefaultService.Project.Mt3dmsData!=null)
           {
               if (MessageBox.Show("mt3dms模型已经存在,此操作将删除原有模型，是否继续？", "注意", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
               {
                   ProjectService.DefaultService.Project.DeleteMT3dMs();

               }
               else
               {
                   return;
               }

               
           }

         

           ProjectService.DefaultService.Project.NewMt3dms();
       }

       static void cbAddMT3d_CanExecute(object sender, CanExecuteRoutedEventArgs e)
       {

           if (!ProjectService.DefaultService.BNullProj)
           {
               if (ProjectService.DefaultService.Project.MfData != null)
               {

                   e.CanExecute = true;
 
               }
               
           }
         
       }

       static void cbRemoveModflow_Executed(object sender, ExecutedRoutedEventArgs e)
       {
           if (MessageBox.Show("此操作将删除modflow模型以及所有的相关数据，是否继续？","注意",MessageBoxButton.YesNo)==MessageBoxResult.Yes)
           {

               ProjectService.DefaultService.Project.DeleteModflow();
               
           }

          
       }

       static void cbRemoveModflow_CanExecute(object sender, CanExecuteRoutedEventArgs e)
       {
           e.CanExecute = !ProjectService.DefaultService.BNullProj;
       }

       static void cbAddModflow_Executed(object sender, ExecutedRoutedEventArgs e)
       {

           if (ProjectService.DefaultService.Project.MfData!=null)
           {
               if (MessageBox.Show("此操作将删除modflow模型以及所有的相关数据，是否继续？", "注意", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
               {

                   ProjectService.DefaultService.Project.DeleteModflow();

                   ProjectService.DefaultService.Project.NewModflow();

                   return;



               }

               else
               {
                   return;
               }
               
           }



           ProjectService.DefaultService.Project.NewModflow();



           

 

       }

       static void cbAddModflow_CanExecute(object sender, CanExecuteRoutedEventArgs e)
       {
           e.CanExecute = !ProjectService.DefaultService.BNullProj;
       }





       static void cbImportShape_Executed(object sender, ExecutedRoutedEventArgs e)
       {
           //throw new NotImplementedException();
       }

       static void cbImportShape_CanExecute(object sender, CanExecuteRoutedEventArgs e)
       {
           e.CanExecute = !ProjectService.DefaultService.BNullProj;
       }

       static void cbImportCAD_Executed(object sender, ExecutedRoutedEventArgs e)
       {
           //throw new NotImplementedException();
       }

       static void cbImportCAD_CanExecute(object sender, CanExecuteRoutedEventArgs e)
       {
           e.CanExecute = !ProjectService.DefaultService.BNullProj;
       }

       static void cbImportBitmap_Executed(object sender, ExecutedRoutedEventArgs e)
       {
           DataOperationModule.DefaultModule.ImportFile(ImportFileType.BITMAP);
           
       }

       static void cbImportBitmap_CanExecute(object sender, CanExecuteRoutedEventArgs e)
       {
           e.CanExecute = !ProjectService.DefaultService.BNullProj;
       }

       static void cbGridFrameProp_Executed(object sender, ExecutedRoutedEventArgs e)
       {
           //在这里编辑gridframe 的属性

           winGridFrameProperty win = new winGridFrameProperty(ProjectService.DefaultService.Project.MapData.GridFrame);
           win.Owner = mainWindow;
           win.ResizeMode = ResizeMode.NoResize;
           win.WindowStartupLocation = WindowStartupLocation.CenterScreen;
           if (win.ShowDialog().Value)
           {
               ProjectService.DefaultService.Project.MapData.EditGridFrame(win.GridFrame);
           }
           
       }

       static void cbGridFrameProp_CanExecute(object sender, CanExecuteRoutedEventArgs e)
       {
           e.CanExecute = !ProjectService.DefaultService.BNullProj;
       }

       static void cbGridFrameFitToCoverage_Executed(object sender, ExecutedRoutedEventArgs e)
       {

           ///在这里循环所有可用的Coverage,然后弹出窗体以提供用户选择

           int[] indexInList = new int[2];

           winConceptualFrame win = new winConceptualFrame(ProjectService.DefaultService.Project.MapData.ConceptualModelCL, ChooseConfigeType.ConceptModelCoverChoose, indexInList);
           //winConceptualFrame win = new winConceptualFrame(ProjectSerivce.DefaultService.Project.MapData.ConceptualModelCL);
           win.Owner = mainWindow;
           win.ResizeMode = ResizeMode.NoResize;
           win.WindowStartupLocation = WindowStartupLocation.CenterScreen;
           if (win.ShowDialog() == true)
           {
               if (win.DialogResult == true)
               //if (win.ShowDialog() == true)
               {



               }

           }

       }

       static void cbGridFrameFitToCoverage_CanExecute(object sender, CanExecuteRoutedEventArgs e)
       {
           e.CanExecute = !ProjectService.DefaultService.BNullProj;
       }

       static void cbBuildPolygon_Executed(object sender, ExecutedRoutedEventArgs e)
       {
           //构建多边形


           Coverage c = (Coverage)e.Parameter;

           //c.BuildPolygonFO();
           c.BuildPolygons();
       }

       static void cbBuildPolygon_CanExecute(object sender, CanExecuteRoutedEventArgs e)
       {
           e.CanExecute = !ProjectService.DefaultService.BNullProj;
       }

       static void cbActiveCellsInCoverage_Executed(object sender, ExecutedRoutedEventArgs e)
       {


           ConceptualModel cm = (ConceptualModel)e.Parameter;

           bool bHaveSet = false;

           foreach (Coverage c in cm.Coverages)
           {
               if (c.Setup.IsUseForModelBoundary == false)
               {
                   continue;

               }
               else
               {
                   bHaveSet = true;
               }
               
           }

           if (bHaveSet==false)
           {
               MessageBox.Show("没有任何图层设置了定义模型边界(active area)!");

               return;
               
           }

           if (ProjectService.DefaultService.Project.MfData != null)
           {

               cm.ActivateCellsInModflow(ProjectService.DefaultService.Project.MfData);


           }
           else
           {

               MessageBox.Show("还未建立对应的modflow数据模型");
           }

          




       }

       static void cbActiveCellsInCoverage_CanExecute(object sender, CanExecuteRoutedEventArgs e)
       {
           if (!ProjectService.DefaultService.BNullProj)
           {
               if (ProjectService.DefaultService.Project.Grid3dData.MainGrid!=null)
               {
                   e.CanExecute = true;
                   
               }
               
           }
       }

       static void cbCoverageMap3DGrid_Executed(object sender, ExecutedRoutedEventArgs e)
       {
           //Coverage c = (Coverage)e.Parameter;


           //if (ProjectSerivce.DefaultService.Project.Grid3dData.Grids.Count > 0)
           //{
           //    if (MessageBox.Show("创建新的三维网格将会使旧的网格被删除，是否继续？", "提示", MessageBoxButton.OKCancel, MessageBoxImage.Information) == MessageBoxResult.Cancel)
           //    {
           //        return;

           //    }

           //    else
           //    {
           //        if (ProjectSerivce.DefaultService.Project.MfData != null)
           //        {
           //            if (MessageBox.Show("创建新的三维网格将会使当前MODFLOW与MODPATH数据删除，是否删除", "提示", MessageBoxButton.OKCancel, MessageBoxImage.Information) == MessageBoxResult.Cancel)
           //            {
           //                return;

           //            }

           //        }
           //    }

           //}




           //GridFrame gf = c.GetCoverageFrame();

           ////HA.ModFlow.Domain.DomainLayer.GridData gdNew = new Domain.DomainLayer.GridData(10, 10, 1, gf.XLength, gf.YLength, gf.ZLength, gf.XOrg, gf.YOrg, gf.ZOrg, gf.RotateAngle);

           //GridConfig config = new GridConfig(false, 10, 10, 1, gf.XLength, gf.YLength, gf.ZLength, gf.XOrg, gf.YOrg, gf.ZOrg, gf.RotateAngle);

           //winGridConfig wc = new winGridConfig(config);

           //if (wc.ShowDialog() == true)
           //{

           //    //确定是否沿用前一key值，以保证绘图系统的正确识别，这里三维网格，目前被认为是唯一的

             

           //    Grid3d gd;
           //    if (ProjectSerivce.DefaultService.Project.Grid3dData.Grids.Count > 0)
           //    {
           //        gd = new Grid3d(wc.GridData, ProjectSerivce.DefaultService.Project.Grid3dData.MainGrid.Key.ToString());

           //    }
           //    else
           //    {
           //        gd = new Grid3d(wc.GridData);
           //    }



           //    ProjectSerivce.DefaultService.Project.Grid3dData.MainGrid = gd;

           //    if (ProjectSerivce.DefaultService.Project.MfData != null)
           //    {
           //        ProjectSerivce.DefaultService.Project.DeleteModflow();

                

           //    }



           //} 
          


       }

       static void cbCoverageMap3DGrid_CanExecute(object sender, CanExecuteRoutedEventArgs e)
       {
           e.CanExecute = !ProjectService.DefaultService.BNullProj;
       }

       static void cbCoverageAttTable_Executed(object sender, ExecutedRoutedEventArgs e)
       {

           Coverage c = (Coverage)e.Parameter;


           string cmId = c.ParentCM.Key.ToString();

          HAGISV2.VectorLayer vl=(HAGISV2.VectorLayer)GisModule.DefaultModule.GisManager.LayerSystem.LayerCollection.GetLayer(c.Key.ToString ());

         

           List<string> ids = new List<string>();


           foreach (HAGISV2.FShape shp in vl.SelectedShapes)
           {
               ids.Add(shp.Id);

           }
           
           winAttributeV2 v2 = new winAttributeV2(c,ProjectService.DefaultService.Project.Units);
           v2.SetSelectedId(ids);
           v2.Owner = mainWindow;
           v2.ResizeMode = ResizeMode.NoResize;
           v2.WindowStartupLocation = WindowStartupLocation.CenterScreen;
           if (v2.ShowDialog() == true)
           {
               c.ResetFOSCTypes(v2.AttributeTable.NewFeatureObjects);


           }

           //winCoverageAttributeTable cat = new winCoverageAttributeTable(c);

           //cat.SetSelectedId(ids);



           //if (cat.ShowDialog()==true)
           //{
           //    c.ResetFO(cat.AttributeTable.NewFeatureObjects);


           //}


       }

       static void cbCoverageAttTable_CanExecute(object sender, CanExecuteRoutedEventArgs e)
       {
           e.CanExecute = !ProjectService.DefaultService.BNullProj;
       }

       static void cbGridFrameMapToGrid3D_Executed(object sender, ExecutedRoutedEventArgs e)
       {




           if (ProjectService.DefaultService.Project.Grid3dData.Grids.Count > 0)
           {
               if (MessageBox.Show("创建新的三维网格将会使旧的网格被删除，是否继续？", "提示", MessageBoxButton.OKCancel, MessageBoxImage.Information) == MessageBoxResult.Cancel)
               {
                   return;

               }

               else
               {
                   if (ProjectService.DefaultService.Project.MfData != null)
                   {
                       if (MessageBox.Show("创建新的三维网格将会使当前MODFLOW与MODPATH数据删除，是否删除", "提示", MessageBoxButton.OKCancel, MessageBoxImage.Information) == MessageBoxResult.Cancel)
                       {
                           return;

                       }

                   }
               }

           }


           GridFrame gf = ProjectService.DefaultService.Project.MapData.GridFrame;

           //1.多个ConcetualModel多个Coverage的时候  如何处理？？？？
           //2.暂时按照一个ConcetualModel一个Coverage处理
           //3.如果RefinePoint的个数为0 则按照正常模式创建网格


           List<HAMath.RefinePoint> refinePointList = new List<HAMath.RefinePoint>();

           try
           {
               #region


               MapDataCollecion mapDataCollection = ProjectService.DefaultService.Project.MapData;
               if (mapDataCollection == null)
               {
                   return;
               }

               if (mapDataCollection.ConceptualModelCL == null)
               {
                   return;
               }
               else
               {

                   //该处以后要修改
                   //因为还不太清楚多个ConcetualModel多个Coverage的情况如何处理  暂时按照暂时按照一个ConcetualModel一个Coverage处理

                   foreach (var item in mapDataCollection.ConceptualModelCL)
                   {
                       if (item != null)
                       {
                           if (item.Coverages != null)
                           {
                               foreach (Coverage coverage in item.Coverages)
                               {
                                   if (coverage != null)
                                   {


                                       if (coverage.Setup.ScTypes[MAPSCType.REFINEPOINTS] == true)
                                       {
                                           foreach (FeatureObject featureObject in coverage.Featureobjects)
                                           {
                                               if (featureObject != null)
                                               {
                                                   //BCType bc =featureObject. GetCurrentBCType();
                                                   //if (bc == null)
                                                   //{
                                                   //    return;
                                                   //}
                                                   if (featureObject is PointFO)
                                                   {
                                                       if (((PointFO)featureObject).RefinePoint.Enabled)
                                                       {

                                                           HAMath.RefinePoint refinePoint = new HAMath.RefinePoint();

                                                           refinePoint.RefinePointCoor.XCoordinate = ((PointFO)featureObject).Coords.X;
                                                           refinePoint.RefinePointCoor.YCoordinate = ((PointFO)featureObject).Coords.Y;
                                                           refinePoint.RefinePointCoor.ZCoordinate = ((PointFO)featureObject).Coords.Z;

                                                           refinePoint.Bisa = ((PointFO)featureObject).RefinePoint.Bias;
                                                           refinePoint.BaseSize = ((PointFO)featureObject).RefinePoint.BaseSize;
                                                           refinePoint.MaxSize = ((PointFO)featureObject).RefinePoint.MaxSize;

                                                           refinePointList.Add(refinePoint);

                                                       }
                                                   }


                                               }


                                           }


                                           //该处以后要修改
                                           //因为还不太清楚多个ConcetualModel多个Coverage的情况如何处理  暂时按照暂时按照一个ConcetualModel一个Coverage处理

                                           break;

                                       }



                                   }


                               }

                           }

                       }
                   }

               }

               #endregion
           }
           catch
           {
               refinePointList = new List<HAMath.RefinePoint>();
           }


           //需要加入是否已经有网格的相关判断，根据gms最新研究，grid3d可能为空

           GridConfig oldGridConfig=null;
           GridConfig config;
         


           if (ProjectService.DefaultService.Project.Grid3dData.MainGrid == null)
           {
              
           }
           else
           {
               oldGridConfig = ProjectService.DefaultService.Project.Grid3dData.MainGrid.ModFlowGrid.Config;
          
 
           }

         
           if (refinePointList.Count > 0)
           {
               //RefinePoint网格
               //GridConfig config = new GridConfig(true, 10, 10, 1, gf.XLength, gf.YLength, gf.ZLength, gf.XOrg, gf.YOrg, gf.ZOrg, gf.RotateAngle);
              
               if (oldGridConfig != null)
               {
                   config = new GridConfig(true, gf.XLength, gf.YLength, gf.ZLength  , gf.XOrg, gf.YOrg, gf.ZOrg  , gf.RotateAngle, oldGridConfig.BiasZ, oldGridConfig.BaseCellSizeZ, oldGridConfig.LimitCellSizeZ, oldGridConfig.CellZ, oldGridConfig.IsUseBLZ, refinePointList);
               }
               else
               {
                   config = new GridConfig(true, gf.XLength, gf.YLength, gf.ZLength, gf.XOrg, gf.YOrg, gf.ZOrg, gf.RotateAngle, 1.0, 5.0, 10.0,4,false, refinePointList);
               }
           }
           else
           {
               //System.Windows.Forms.MessageBox.Show("根据您的设置得到的有效的 RefinePoint 点的个数为 0 ，请检查您的参数设置！将取消您的该次操作！");
             
               //return;

               //System.Windows.Forms.MessageBox.Show("根据您的设置得到的有效的 RefinePoint 点的个数为 0 ！将为您创建常规网格！");
               //正常网格

               if (oldGridConfig != null)
               {
                   config = new GridConfig(false, gf.XLength , gf.YLength , gf.ZLength , gf.XOrg , gf.YOrg ,gf.ZOrg ,gf.RotateAngle , oldGridConfig.BiasX, oldGridConfig.BaseCellSizeX, oldGridConfig.LimitCellSizeX, oldGridConfig.CellX, oldGridConfig.IsUseBLX,
                       oldGridConfig.BiasY, oldGridConfig.BaseCellSizeY, oldGridConfig.LimitCellSizeY, oldGridConfig.CellY, oldGridConfig.IsUseBLY,
                       oldGridConfig.BiasZ, oldGridConfig.BaseCellSizeZ, oldGridConfig.LimitCellSizeZ, oldGridConfig.CellZ, oldGridConfig.IsUseBLZ);
               }
               else
               {

                   //这里需要加入有关的判断，考虑旧网格不存在的情况

                   config = new GridConfig(false,10,10,1, gf.XLength, gf.YLength, gf.ZLength, gf.XOrg, gf.YOrg,gf.ZOrg, gf.RotateAngle);


                   
                   //config = new GridConfig(false, 100, 100, 40, 0, 0, 0, 0, 1, 10, 50, 8, false, 1, 10, 50, 10, false, 1, 4, 20, 4, false);
               }


           }


           //HA.ModFlow.Domain.DomainLayer.GridData gdNew = new Domain.DomainLayer.GridData(10, 10, 1, gf.XLength, gf.YLength, gf.ZLength, gf.XOrg, gf.YOrg, gf.ZOrg, gf.RotateAngle);
           //GridConfig config = new GridConfig(true , 10, 10, 1, gf.XLength, gf.YLength, gf.ZLength, gf.XOrg, gf.YOrg, gf.ZOrg, gf.RotateAngle);

           winGridConfig wc = new winGridConfig(config);
           wc.Owner = mainWindow;
           wc.ResizeMode = ResizeMode.NoResize;
           wc.WindowStartupLocation = WindowStartupLocation.CenterScreen;
           if (wc.ShowDialog() == true)
           {

               //确定是否沿用前一key值，以保证绘图系统的正确识别，这里三维网格，目前被认为是唯一的

               Grid3d gd;
               if (ProjectService.DefaultService.Project.Grid3dData.Grids.Count > 0)
               {
                   gd = new Grid3d(wc.GridData, ProjectService.DefaultService.Project.Grid3dData.MainGrid.Key.ToString());

               }
               else
               {
                   gd = new Grid3d(wc.GridData);
               }



               if (ProjectService.DefaultService.Project.MfData != null)
               {
                   ProjectService.DefaultService.Project.DeleteModflow();




               }


               ProjectService.DefaultService.Project.Grid3dData.MainGrid = gd;


               //网格改变后，改变显示选项中的一些参数设置，例如：向量的长度。

               if (ProjectService.DefaultService.Project.DisplayOption2 != null && ProjectService.DefaultService.Project.DisplayOption2.DoGrid3dData != null && ProjectService.DefaultService.Project.DisplayOption2.DoGrid3dData.Grid3d != null)
               {
                   if (ProjectService.DefaultService.Project.DisplayOption2.DoGrid3dData.Grid3d.Vector != null)
                   {

                       if (ProjectService.DefaultService.Project.DisplayOption2.DoGrid3dData.Grid3d.Vector.IsAutoCompLength == true)
                       {
                           Grid3d grid3D = ProjectService.DefaultService.Project.Grid3dData.MainGrid;

                           int colindex = grid3D.ModFlowGrid.ColCoords.Length - 1;
                           int rowindex = grid3D.ModFlowGrid.RowCoords.Length - 1;
                           double col = grid3D.ModFlowGrid.ColCoords[colindex];
                           double row = grid3D.ModFlowGrid.RowCoords[rowindex];
                           double value = FlowVectorsAutoCompute.ComputeLength(grid3D.ModFlowGrid.ColsCount, grid3D.ModFlowGrid.RowsCount, col, row);
                           ProjectService.DefaultService.Project.DisplayOption2.DoGrid3dData.Grid3d.Vector.Length = value;

                       }

                       if (ProjectService.DefaultService.Project.DisplayOption2.DoGrid3dData.Grid3d.Vector.IsVaryLength == true && ProjectService.DefaultService.Project.DisplayOption2.DoGrid3dData.Grid3d.Vector.IsAutoCompScaling == true)
                       {
                           DSModflow ds = (DSModflow)ProjectService.DefaultService.Project.Grid3dData.MainGrid.GetDatasetCollection(DataConstName.ModflowResult);

                           if (ds.VectorGridData != null)
                           {
                               double range = ds.VectorGridData.MaxVectorValue - ds.VectorGridData.MinVectorValue;
                               double scaValue = FlowVectorsAutoCompute.ComputeScalingRatio(range, ProjectService.DefaultService.Project.DisplayOption2.DoGrid3dData.Grid3d.Vector.Length);

                           }

                       }

                   }
               }



           } 
          
       }

       static void cbGridFrameMapToGrid3D_CanExecute(object sender, CanExecuteRoutedEventArgs e)
       {
           if (!ProjectService.DefaultService.BNullProj)
           {
               e.CanExecute = true;

           }

           //else
           //{
           //    if (ProjectSerivce.DefaultService.Project.Grid3dData.MainGrid != null)
           //    {
           //        e.CanExecute = true;

           //    }

           //    else
           //    {

           //        e.CanExecute = false;

 
           //    }

           //}




         
       }

       static void cbCoverageMapToModFlow_Executed(object sender, ExecutedRoutedEventArgs e)
       {
           Coverage c = (Coverage)e.Parameter;

           List<Coverage> lst=new List<Coverage> ();
           lst.Add (c);

           c.ParentCM.MapToModflow(ProjectService.DefaultService.Project.MfData, lst,false,true);
        
          
       }

       static void cbCoverageMapToModFlow_CanExecute(object sender, CanExecuteRoutedEventArgs e)
       {
           if (!ProjectService.DefaultService.BNullProj)
           {
               if (ProjectService.DefaultService.Project.MfData != null)
               {
                   e.CanExecute = true;

               }

           }
       }

       static void cbCMMaptoModFlow_Executed(object sender, ExecutedRoutedEventArgs e)
       {
           bool isNewModflow = false;
           ConceptualModel cm = (ConceptualModel)e.Parameter;

           //判断Modflow是否已建立
           if (ProjectService.DefaultService.Project.MfData == null)
           {
               isNewModflow = true;
               ProjectService.DefaultService.Project.NewModflow();
               ProjectService.DefaultService.Project.MfData.StressPeriods.InnerList.Clear();
               for (int i = 0; i < cm.Model.NPeriods; i++)
               {
                   ProjectService.DefaultService.Project.MfData.StressPeriods.InnerList.Add(new StressPeriod());
               }

               ProjectService.DefaultService.Project.MfData.ModelOption.InnerPack = cm.Model.InnerPack;
           }

           cm.MapToModflow(ProjectService.DefaultService.Project.MfData,isNewModflow);


       }

       static void cbCMMaptoModFlow_CanExecute(object sender, CanExecuteRoutedEventArgs e)
       {
           if (!ProjectService.DefaultService.BNullProj && ProjectService.DefaultService.Project.Grid3dData.Grids.Count > 0 )
           {
               e.CanExecute = true;
           }
       }

       static void cbGridFrameProperty_Executed(object sender, ExecutedRoutedEventArgs e)
       {


         
           
       }

       static void cbGridFrameProperty_CanExecute(object sender, CanExecuteRoutedEventArgs e)
       {
           e.CanExecute = !ProjectService.DefaultService.BNullProj;
       }

       static void cbConceptualModelProperty_Executed(object sender, ExecutedRoutedEventArgs e)
       {
           ConceptualModel cmm = (ConceptualModel)e.Parameter;

           winConceptualModelProperty cm = new winConceptualModelProperty(cmm,ProjectService.DefaultService.Project.Units);
           cm.Owner = mainWindow;
           cm.ResizeMode = ResizeMode.NoResize;
           cm.WindowStartupLocation = WindowStartupLocation.CenterScreen;
           cm.ShowDialog();
         

       }

       static void cbConceptualModelProperty_CanExecute(object sender, CanExecuteRoutedEventArgs e)
       {
           e.CanExecute = !ProjectService.DefaultService.BNullProj;
       }

       static void cbCoverageSetup_Executed(object sender, ExecutedRoutedEventArgs e)
       {
           Coverage c = (Coverage)e.Parameter;

           winCoverageSetup cs = new winCoverageSetup(c);
           cs.Owner = mainWindow;
           cs.ResizeMode = ResizeMode.NoResize;
           cs.WindowStartupLocation = WindowStartupLocation.CenterScreen;
           if (cs.ShowDialog()==true)
           {
               c.Setup = cs.PCCoverageSetup.Setup;
               c.Name = cs.PCCoverageSetup.CoverageName;
               
           } 
       }

       static void cbCoverageSetup_CanExecute(object sender, CanExecuteRoutedEventArgs e)
       {
           e.CanExecute = !ProjectService.DefaultService.BNullProj;
       }

       static void cbDuplicateCmCoverage_Executed(object sender, ExecutedRoutedEventArgs e)
       {
           //throw new NotImplementedException();
           Coverage c = (Coverage)e.Parameter;
           c.ParentCM.DuplicateCoverage(c);

        

       }

       static void cbDuplicateCmCoverage_CanExecute(object sender, CanExecuteRoutedEventArgs e)
       {
           e.CanExecute = !ProjectService.DefaultService.BNullProj;
       }

       static void cbRemoveCmCoverage_Executed(object sender, ExecutedRoutedEventArgs e)
       {
           //throw new NotImplementedException();

           Coverage c = (Coverage)e.Parameter;

           ConceptualModel cm = c.ParentCM;
           cm.RemoveCoverage(c);






       }

       static void cbRemoveCmCoverage_CanExecute(object sender, CanExecuteRoutedEventArgs e)
       {
           e.CanExecute = !ProjectService.DefaultService.BNullProj;
       }

       static void cbAddCmCoverage_Executed(object sender, ExecutedRoutedEventArgs e)
       {
           object[] parameters=e.Parameter as object[];

           ConceptualModel cm = (ConceptualModel)parameters[0];
           Coverage c = cm.NewCoverage((HAUtil.LAYERCOVERAGETYPE)parameters[1]);
           if (c.CoverageType == HAUtil.LAYERCOVERAGETYPE.水文地质层)
           {
               c.CheckedGeoParam[0] = ((CheckBox)parameters[2]).IsChecked.Value;
               c.CheckedGeoParam[1] = ((CheckBox)parameters[3]).IsChecked.Value;
               c.CheckedGeoParam[2] = ((CheckBox)parameters[4]).IsChecked.Value;
               c.CheckedGeoParam[3] = ((CheckBox)parameters[5]).IsChecked.Value;
           }

           cm.AddCoverage(c);

           //添加图层后直接设置图层属性
           winCoverageSetup cs = new winCoverageSetup(c);
           cs.Owner = mainWindow;
           cs.ResizeMode = ResizeMode.NoResize;
           cs.WindowStartupLocation = WindowStartupLocation.CenterScreen;
           if (cs.ShowDialog() == true)
           {
               c.Setup = cs.PCCoverageSetup.Setup;
               c.Name = cs.PCCoverageSetup.CoverageName;

           } 
          
       }

       static void cbAddCmCoverage_CanExecute(object sender, CanExecuteRoutedEventArgs e)
       {
           e.CanExecute = !ProjectService.DefaultService.BNullProj;
       }




       static void cbRemoveConceptualModel_Executed(object sender, ExecutedRoutedEventArgs e)
       {
           ConceptualModel cmvm = (ConceptualModel)e.Parameter;

           ProjectService.DefaultService.Project.MapData.RemoveConceputalModel(cmvm);


       }

       static void cbRemoveConceptualModel_CanExecute(object sender, CanExecuteRoutedEventArgs e)
       {
           e.CanExecute = !ProjectService.DefaultService.BNullProj;
       }

       static void cbAddConceptualModel_Executed(object sender, ExecutedRoutedEventArgs e)
       {

           //首先要弹出一个窗体，询问属性

          ConceptualModel cm=  ProjectService.DefaultService.Project.MapData.NewConcetualModel();

          //ProjectService.DefaultService.Project.MapData.AddConceptualModel(cm);

          winConceptualModelProperty win = new winConceptualModelProperty(cm, ProjectService.DefaultService.Project.Units);

           //由于内部代码确定时执行  此处只做show操作
          win.ShowDialog();

          ProjectService.DefaultService.Project.MapData.AddConceptualModel(cm);


           ////添加默认图层
           //Coverage c = cm.NewCoverage();

           //cm.AddCoverage(c);

           ////添加图层后直接设置图层属性
           //winCoverageSetup cs = new winCoverageSetup(c);
           //cs.Owner = mainWindow;
           //cs.ResizeMode = ResizeMode.NoResize;
           //cs.WindowStartupLocation = WindowStartupLocation.CenterScreen;
           //if (cs.ShowDialog() == true)
           //{
           //    c.Setup = cs.PCCoverageSetup.Setup;
           //    c.Name = cs.PCCoverageSetup.CoverageName;

           //}



       }

       static void cbAddConceptualModel_CanExecute(object sender, CanExecuteRoutedEventArgs e)
       {
           e.CanExecute = !ProjectService.DefaultService.BNullProj;
       }

       static void cbRemoveCoverage_Executed(object sender, ExecutedRoutedEventArgs e)
       {
           Coverage c = (Coverage)e.Parameter;

           ProjectService.DefaultService.Project.MapData.RemoveCoverage(c);

       }

       static void cbRemoveCoverage_CanExecute(object sender, CanExecuteRoutedEventArgs e)
       {
           e.CanExecute = !ProjectService.DefaultService.BNullProj;
       }

       static void cbAddCoverage_Executed(object sender, ExecutedRoutedEventArgs e)
       {


           //Coverage c = new Coverage();

           //ProjectService.DefaultService.Project.MapData.AddCoverage(c);
           
       }

       static void cbAddCoverage_CanExecute(object sender, CanExecuteRoutedEventArgs e)
       {
           e.CanExecute = !ProjectService.DefaultService.BNullProj;
       }

       static void cbRemoveTin_Executed(object sender, ExecutedRoutedEventArgs e)
       {
           throw new NotImplementedException();
       }

       static void cbRemoveTin_CanExecute(object sender, CanExecuteRoutedEventArgs e)
       {
           e.CanExecute = !ProjectService.DefaultService.BNullProj;
       }

       static void cbAddTin_Executed(object sender, ExecutedRoutedEventArgs e)
       {
           throw new NotImplementedException();
       }

       static void cbAddTin_CanExecute(object sender, CanExecuteRoutedEventArgs e)
       {
           e.CanExecute = !ProjectService.DefaultService.BNullProj;
       }

       static void cbRemoveBorehole_Executed(object sender, ExecutedRoutedEventArgs e)
       {
           throw new NotImplementedException();
       }

       static void cbRemoveBorehole_CanExecute(object sender, CanExecuteRoutedEventArgs e)
       {
           e.CanExecute = !ProjectService.DefaultService.BNullProj;
       }

       static void cbAddBorehole_Executed(object sender, ExecutedRoutedEventArgs e)
       {
           
           throw new NotImplementedException();
       }

       static void cbAddBorehole_CanExecute(object sender, CanExecuteRoutedEventArgs e)
       {
           e.CanExecute = !ProjectService.DefaultService.BNullProj;
       }

       static void cbRemoveGrid3D_Executed(object sender, ExecutedRoutedEventArgs e)
       {
           Grid3d grid = ProjectService.DefaultService.Project.Grid3dData.MainGrid;
           if (grid != null)
           {

               if (MessageBox.Show("此操作将删除网格 modflow模型以及所有的相关数据，是否继续？", "注意", MessageBoxButton.YesNo) 
                   != MessageBoxResult.Yes)
               {
                   return;

               }



               if (ProjectService.DefaultService.Project.MfData!=null)
               {
                   ProjectService.DefaultService.Project.DeleteModflow();
                   
               }

               ProjectService.DefaultService.Project.CurrentViewPort.Number = 1;
               ProjectService.DefaultService.Project.CurrentViewPort.ViewType = ProjectViewType.TOP;

               GisModule.DefaultModule.GisManager.VIEWMODE = HAGISV2.FMAPVIEW.NORMAL;

               ProjectService.DefaultService.Project.Grid3dData.Remove(grid);
 
           }


          
       }

       static void cbRemoveGrid3D_CanExecute(object sender, CanExecuteRoutedEventArgs e)
       {
           e.CanExecute = !ProjectService.DefaultService.BNullProj;
       }

       static void cbAddGrid3D_Executed(object sender, ExecutedRoutedEventArgs e)
       {
           if (ProjectService.DefaultService.Project.Grid3dData.Grids.Count>0)
           {
               if (MessageBox.Show("创建新的三维网格将会使旧的网格被删除，是否继续？", "提示", MessageBoxButton.OKCancel, MessageBoxImage.Information) == MessageBoxResult.Cancel)
               {
                   return;

               }

               else
               {
                   if (ProjectService.DefaultService.Project.MfData!=null)
                   {
                       if (MessageBox.Show("创建新的三维网格将会使当前MODFLOW与MODPATH数据删除，是否删除","提示",MessageBoxButton.OKCancel,MessageBoxImage.Information)==MessageBoxResult.Cancel)
                       {
                           return;
                           
                       }
                       
                   }
               }
               
           }



           ///当第一设置网格的情况,需要特殊考虑
           ///

            GridConfig config;
            if (ProjectService.DefaultService.Project.Grid3dData.MainGrid != null)
            {
                config = ProjectService.DefaultService.Project.Grid3dData.MainGrid.ModFlowGrid.Config;

            }
            else
            {
                config = new GridConfig();
            }


          
           config.IsRefinedPointMode = false;

           winGridConfig wc = new winGridConfig(config);
           wc.Owner = mainWindow;
           wc.ResizeMode = ResizeMode.NoResize;
           wc.WindowStartupLocation = WindowStartupLocation.CenterScreen;
           if (wc.ShowDialog() == true)
           {

               //确定是否沿用前一key值，以保证绘图系统的正确识别，这里三维网格，目前被认为是唯一的

               Grid3d gd;
               if (ProjectService.DefaultService.Project.Grid3dData.Grids.Count > 0)
               {
                   gd = new Grid3d(wc.GridData,ProjectService.DefaultService.Project.Grid3dData.MainGrid.Key.ToString());

               }
               else
               {
                   gd = new Grid3d(wc.GridData);
               }



               if (ProjectService.DefaultService.Project.MfData != null)
               {
                   ProjectService.DefaultService.Project.DeleteModflow();




               }

            

               ProjectService.DefaultService.Project.Grid3dData.MainGrid = gd;

             
              //网格改变后，改变显示选项中的一些参数设置，例如：向量的长度。

               if (ProjectService.DefaultService.Project.DisplayOption2 !=null && ProjectService.DefaultService.Project.DisplayOption2 .DoGrid3dData !=null &&ProjectService.DefaultService.Project.DisplayOption2 .DoGrid3dData .Grid3d !=null )
               {
                   if (ProjectService.DefaultService.Project.DisplayOption2 .DoGrid3dData .Grid3d .Vector  !=null )
                   {

                       if (ProjectService.DefaultService.Project.DisplayOption2 .DoGrid3dData .Grid3d .Vector.IsAutoCompLength ==true )
                       {
                           Grid3d grid3D = ProjectService.DefaultService.Project.Grid3dData.MainGrid;

                           int colindex = grid3D.ModFlowGrid.ColCoords.Length - 1;
                           int rowindex = grid3D.ModFlowGrid.RowCoords.Length - 1;
                           double col = grid3D.ModFlowGrid.ColCoords[colindex];
                           double row = grid3D.ModFlowGrid.RowCoords[rowindex];
                           double value = FlowVectorsAutoCompute.ComputeLength(grid3D.ModFlowGrid.ColsCount, grid3D.ModFlowGrid.RowsCount, col, row);
                           ProjectService.DefaultService.Project.DisplayOption2.DoGrid3dData.Grid3d.Vector.Length = value;
                                                      
                       }

                       if (ProjectService.DefaultService.Project.DisplayOption2.DoGrid3dData.Grid3d.Vector.IsVaryLength == true && ProjectService.DefaultService.Project.DisplayOption2.DoGrid3dData.Grid3d.Vector.IsAutoCompScaling == true)
                       {
                           DSModflow ds = (DSModflow)ProjectService.DefaultService.Project.Grid3dData.MainGrid.GetDatasetCollection(DataConstName.ModflowResult);

                           if (ds.VectorGridData != null)
                           {
                               double range = ds.VectorGridData.MaxVectorValue - ds.VectorGridData.MinVectorValue;
                               double scaValue = FlowVectorsAutoCompute.ComputeScalingRatio(range, ProjectService.DefaultService.Project.DisplayOption2.DoGrid3dData.Grid3d.Vector.Length);

                           }

                       }

                       
                   }
               }



           } 


      

       }

       static void cbAddGrid3D_CanExecute(object sender, CanExecuteRoutedEventArgs e)
       {
           e.CanExecute = !ProjectService.DefaultService.BNullProj;
       }

       static void cbRemoveGrid2D_Executed(object sender, ExecutedRoutedEventArgs e)
       {
           if (true)
           {
               
           }
       }

       static void cbRemoveGrid2D_CanExecute(object sender, CanExecuteRoutedEventArgs e)
       {
           e.CanExecute = !ProjectService.DefaultService.BNullProj;
       }

       static void cbAddGrid2D_Executed(object sender, ExecutedRoutedEventArgs e)
       {
           throw new NotImplementedException();
       }

       static void cbAddGrid2D_CanExecute(object sender, CanExecuteRoutedEventArgs e)
       {
           e.CanExecute = !ProjectService.DefaultService.BNullProj;
       }

      

       static void cbImportTxt_Executed(object sender, ExecutedRoutedEventArgs e)
       {
           DataOperationModule.DefaultModule.ImportFile(ImportFileType.TXTCSV);
       }

       static void cbImportTxt_CanExecute(object sender, CanExecuteRoutedEventArgs e)
       {
           e.CanExecute = !ProjectService.DefaultService.BNullProj;
       }

       static void cbImportDem_Executed(object sender, ExecutedRoutedEventArgs e)
       {
           DataOperationModule.DefaultModule.ImportFile(ImportFileType.DEM);
       }
       static void cbImportDem_CanExecute(object sender, CanExecuteRoutedEventArgs e)
       {
           e.CanExecute = !ProjectService.DefaultService.BNullProj;
       }

       static void cbExportBitmap_Executed(object sender, ExecutedRoutedEventArgs e)
       {
           winExportBitmap exportBitmap;
           if (UIModule.DefaultModule.RendererViewModel.View2D)
           {
               HAGISV2.IsolineLayer layer = GisModule.DefaultModule.GisManager.LayerSystem.LayerCollection.GetLayer(GisModule.DefaultModule.IsolineLayerId) as HAGISV2.IsolineLayer;

               if (layer == null) return;
               layer.UseLayerLegend = true;

               exportBitmap = new winExportBitmap(GisModule.DefaultModule.DefaultMap);

               exportBitmap.WindowStartupLocation = WindowStartupLocation.CenterOwner;
               exportBitmap.ResizeMode = ResizeMode.NoResize;
               exportBitmap.Owner = GisModule.mainWindow;
               exportBitmap.ShowDialog();

               layer.UseLayerLegend = false;

           }
           else
           {
               exportBitmap = new winExportBitmap(Render3dModule.DefaultModule.VtkControl.RenderWindow);

               exportBitmap.WindowStartupLocation = WindowStartupLocation.CenterOwner;
               exportBitmap.ResizeMode = ResizeMode.NoResize;
               exportBitmap.Owner = GisModule.mainWindow;
               exportBitmap.ShowDialog();

               //winExportBitmapForm3D exportBitmap = new winExportBitmapForm3D();
               //exportBitmap.ResizeMode = ResizeMode.NoResize;
               //exportBitmap.WindowStartupLocation = WindowStartupLocation.CenterOwner;
               //exportBitmap.Owner = GisModule.mainWindow;
               //if (exportBitmap.ShowDialog().Value)
               //{
               //    Render3dModule.DefaultModule.VtkScene.SaveScreenShot(exportBitmap.ScreenSetup);
               //}
           }
           
       }
       static void cbExportBitmap_CanExecute(object sender, CanExecuteRoutedEventArgs e)
       {
           e.CanExecute = !ProjectService.DefaultService.BNullProj;
       }


       //cbExportBitmap_CanExecute
       //    cbExportBitmap_Executed

    }
}
